import java.util.HashMap;
import java.util.Map;

public class Solution1406 {

    Map<Integer,int[]> map=new HashMap<>();

    public String stoneGameIII(int[] stoneValue) {
        int[] points=dfs(stoneValue,0);
        if (points[0]==points[1]){
            return "Tie";
        }else if (points[0]>points[1]){
            return "Alice";
        }else {
            return "Bob";
        }
    }

    private int[] dfs(int[] stoneValue, int k) {
        if (k==stoneValue.length){
            return new int[]{0,0};
        }
        if (!map.containsKey(k)){
            int[] ans=new int[2];
            int[] t1=dfs(stoneValue,k+1);
            ans[1]=t1[0];
            ans[0]=t1[1]+stoneValue[k];
            if (k+1<stoneValue.length){
                int[] t2=dfs(stoneValue,k+2);
                if (t2[1]+stoneValue[k]+stoneValue[k+1]>ans[0]){
                    ans[0]=t2[1]+stoneValue[k]+stoneValue[k+1];
                    ans[1]=t2[0];
                }
            }
            if (k+2<stoneValue.length){
                int[] t3=dfs(stoneValue,k+3);
                if (t3[1]+stoneValue[k]+stoneValue[k+1]+stoneValue[k+2]>ans[0]){
                    ans[0]=t3[1]+stoneValue[k]+stoneValue[k+1]+stoneValue[k+2];
                    ans[1]=t3[0];
                }
            }
            map.put(k,ans);
        }
        return map.get(k);
    }

    public static void main(String[] args) {
        System.out.println(new Solution1406().stoneGameIII(new int[]{1,2,3,7}));
    }
}
